/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package cl.zeke.pizzastore.negocio.entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author taller
 */
@Entity
@Table(name = "INGREDIENTE")
@NamedQueries({
    @NamedQuery(name = "Ingrediente.findAll", query = "SELECT i FROM Ingrediente i"),
    @NamedQuery(name = "Ingrediente.findByIdIngrediente", query = "SELECT i FROM Ingrediente i WHERE i.idIngrediente = :idIngrediente"),
    @NamedQuery(name = "Ingrediente.findByNombre", query = "SELECT i FROM Ingrediente i WHERE i.nombre = :nombre"),
    @NamedQuery(name = "Ingrediente.findByStock", query = "SELECT i FROM Ingrediente i WHERE i.stock = :stock"),
    @NamedQuery(name = "Ingrediente.findByCostoUnidad", query = "SELECT i FROM Ingrediente i WHERE i.costoUnidad = :costoUnidad")})
public class Ingrediente implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID_INGREDIENTE")
    private Long idIngrediente;
    @Basic(optional = false)
    @Column(name = "NOMBRE")
    private String nombre;
    @Basic(optional = false)
    @Column(name = "STOCK")
    private int stock;
    @Column(name = "COSTO_UNIDAD")
    private Integer costoUnidad;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "ingrediente", fetch = FetchType.LAZY)
    private List<PizzaIngrediente> pizzaIngredienteList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "ingrediente", fetch = FetchType.LAZY)
    private List<CompraIngrediente> compraIngredienteList;

    public Ingrediente() {
    }

    public Ingrediente(Long idIngrediente) {
        this.idIngrediente = idIngrediente;
    }

    public Ingrediente(Long idIngrediente, String nombre, int stock) {
        this.idIngrediente = idIngrediente;
        this.nombre = nombre;
        this.stock = stock;
    }

    public Long getIdIngrediente() {
        return idIngrediente;
    }

    public void setIdIngrediente(Long idIngrediente) {
        this.idIngrediente = idIngrediente;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public int getStock() {
        return stock;
    }

    public void setStock(int stock) {
        this.stock = stock;
    }

    public Integer getCostoUnidad() {
        return costoUnidad;
    }

    public void setCostoUnidad(Integer costoUnidad) {
        this.costoUnidad = costoUnidad;
    }

    public List<PizzaIngrediente> getPizzaIngredienteList() {
        return pizzaIngredienteList;
    }

    public void setPizzaIngredienteList(List<PizzaIngrediente> pizzaIngredienteList) {
        this.pizzaIngredienteList = pizzaIngredienteList;
    }

    public List<CompraIngrediente> getCompraIngredienteList() {
        return compraIngredienteList;
    }

    public void setCompraIngredienteList(List<CompraIngrediente> compraIngredienteList) {
        this.compraIngredienteList = compraIngredienteList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idIngrediente != null ? idIngrediente.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Ingrediente)) {
            return false;
        }
        Ingrediente other = (Ingrediente) object;
        if ((this.idIngrediente == null && other.idIngrediente != null) || (this.idIngrediente != null && !this.idIngrediente.equals(other.idIngrediente))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "cl.zeke.pizzastore.negocio.entities.Ingrediente[ idIngrediente=" + idIngrediente + " ]";
    }
    
}
